$(function(){
	/*1. 获取表单序列化  serialize  serializeArray序列化为数组*/
	$(".mui-btn-primary").on("tap",function(){
		var data =$("form").serialize();
		/*2. */
		var dataObj =  LT.serilize2Object(data);
		if(dataObj){
			if(!dataObj.username){
				mui.toast("用户名不能为空");
				return false;
			}
			if(!dataObj.password){
				mui.toast("密码不能为空");
				return false;
			}
			$.ajax({
				url:"/user/login",
				type:"post",
				data:dataObj,
				dataType:"json",
				success: function(res){
					if(res.error){
						mui.toast(res.message);
						return false;
					}
					if (res.success == true){
						var returnUrl =  location.search.replace("?returnRul=",'');
						if(returnUrl != ''){
							location.href = returnUrl;
						}else {
							location.href = LT.userUrl;
						}
					}

				}
			});
		}
	})


});	